<!DOCTYPE html>
<html>

<head>
  <title>Organisations - AIL</title>
	<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}">

  <!-- Core CSS -->
	<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
	<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
	<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">

  <!-- JS -->
	<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
	<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
	<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
	<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
	<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>

</head>
<body>

{% include 'nav_bar.html' %}

	<div class="container-fluid">
		<div class="row">
            {% include 'settings/menu_sidebar.html' %}
			<div class="col-12 col-lg-10" id="core_content">

                <h3>AIL Organisations:</h3>
                <span>Active <span class="badge badge-primary">{{ meta['active'] }}</span></span>

                <table id="tableorgs" class="table table-hover table-striped">
                    <thead class="thead-dark">
                    <tr>
                        <th>Name</th>
                        <th>uuid</th>
                        <th>Description</th>
                        <th>Created at</th>
                        <th>Nb Users</th>
                        <th>Actions</th>
                    </tr>
                    </thead>
                    <tbody id="tbody_last_crawled">
                    {% for org in meta['orgs'] %}
                        <tr>
                            <td>{{org['name']}}</td>
                            <td><a href="{{ url_for('settings_b.organisation', uuid=org['uuid']) }}">{{ org['uuid'] }}</a></td>
                            <td>{{org['description']}}</td>
                            <td>
                                {% if org['date_created'] %}
                                    {{org['date_created']}}
                                {% endif %}
                            </td>
                            <td>{{org['nb_users']}}</td>
                            <td>
                                <div class="d-flex justify-content-start">
{#                                    <a class="btn btn-outline-primary ml-3 px-1 py-0" href="{{ url_for('settings_b.edit_user', org_uuid=org['uuid']) }}">#}
{#                                        <i class="fas fa-pencil-alt"></i>#}
{#                                    </a>#}
                                    <a class="btn btn-outline-danger ml-3 px-1 py-0" href="{{ url_for('settings_b.delete_org', uuid=org['uuid']) }}">
                                        <i class="fas fa-trash-alt"></i>
                                    </a>
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>

    	    </div>
		</div>
	</div>
</body>

<script>
$(document).ready(function(){
    $("#nav_orgs_list").addClass("active");
	$("#nav_orgs_management").removeClass("text-muted");
    $('#tableorgs').DataTable({
        "aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
        "iDisplayLength": 10,
        "order": [[ 0, "asc" ]]
    });
});

function toggle_sidebar(){
	if($('#nav_menu').is(':visible')){
		$('#nav_menu').hide();
		$('#side_menu').removeClass('border-right')
		$('#side_menu').removeClass('col-lg-2')
		$('#core_content').removeClass('col-lg-10')
	}else{
		$('#nav_menu').show();
		$('#side_menu').addClass('border-right')
		$('#side_menu').addClass('col-lg-2')
		$('#core_content').addClass('col-lg-10')
	}
}

</script>

</html>
